<%--
  Created by IntelliJ IDEA.
  User: Tang'ya'kang
  Date: 2023/5/14
  Time: 0:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Page_Nav</title>
</head>
<body>

<nav aria-label="Page navigation example" class="box1">
    <ul class="pagination justify-content-center">
        <c:if test="${requestScope.books.pageNo==1}">
            <li class="page-item">
                <a class="page-link" href="${requestScope.books.url}1">首页</a>
            </li>
            <li class="page-item"><a class="page-link" href="${requestScope.books.url}${requestScope.books.pageNo-1}">上一页</a></li>
        </c:if>
        <c:if test="${requestScope.books.pageNo!=1}">
            <li class="page-item disabled">
                <a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=1">首页</a>
            </li>
            <li class="page-item disabled"><a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${requestScope.books.pageNo-1}">上一页</a></li>
        </c:if>

        <c:if test="${requestScope.books.pageTotal<=5}">
            <c:forEach var="i" begin="1" end="${requestScope.books.pageTotal}">
                <c:if test="${i!=requestScope.books.pageNo}">
                    <li class="page-item"><a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${i}">${i}</a></li>
                </c:if>
                <c:if test="${i==requestScope.books.pageNo}">
                    <li class="page-item disabled"><a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${i}">【${i}】</a></li>
                </c:if>
            </c:forEach>
        </c:if>

        <c:if test="${requestScope.books.pageTotal>5}">
            <c:if test="${requestScope.books.pageNo<=3}">
                <c:forEach begin="1" end="5" var="i">
                    <c:if test="${i!=requestScope.books.pageNo}">
                        <li class="page-item"><a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${i}">${i}</a></li>
                    </c:if>
                    <c:if test="${i==requestScope.books.pageNo}">
                        <li class="page-item disabled"><a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${i}">【${i}】</a></li>
                    </c:if>
                </c:forEach>
            </c:if>
            <c:if test="${requestScope.books.pageNo+2>=requestScope.books.pageTotal}">
                <c:forEach begin="${requestScope.books.pageTotal-4}" end="${requestScope.books.pageTotal}" var="i">
                    <c:if test="${i!=requestScope.books.pageNo}">
                        <li class="page-item"><a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${i}">${i}</a></li>
                    </c:if>
                    <c:if test="${i==requestScope.books.pageNo}">
                        <li class="page-item disabled"><a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${i}">【${i}】</a></li>
                    </c:if>
                </c:forEach>
            </c:if>
            <c:if test="${requestScope.books.pageNo>3&&requestScope.books.pageNo<requestScope.books.pageTotal-2}">
                <c:forEach begin="${requestScope.books.pageNo-2}" end="${requestScope.books.pageNo+2}" var="i">
                    <c:if test="${i!=requestScope.books.pageNo}">
                        <li class="page-item"><a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${i}">${i}</a></li>
                    </c:if>
                    <c:if test="${i==requestScope.books.pageNo}">
                        <li class="page-item disabled"><a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${i}">【${i}】</a></li>
                    </c:if>
                </c:forEach>
            </c:if>
        </c:if>

        <c:if test="${requestScope.books.pageNo!=requestScope.books.pageTotal}">
            <li class="page-item"><a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${requestScope.books.pageNo+1}">下一页</a></li>
            <li class="page-item">
                <a class="page-link" href="${requestScope.books.url}${requestScope.books.pageTotal}">末页</a>
            </li>
        </c:if>

        <c:if test="${requestScope.books.pageNo==requestScope.books.pageTotal}">
            <li class="page-item disabled"><a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${requestScope.books.pageNo+1}">下一页</a></li>
            <li class="page-item disabled">
                <a class="page-link" href="${requestScope.books.url}?action=PageByPageNo&pageNo=${requestScope.books.pageTotal}">末页</a>
            </li>
        </c:if>

        <%--                    以下必须的--%>
        <li class="page-item disabled">
            <a class="page-link">共计${requestScope.books.pageTotal}页,${requestScope.books.pageTotalCount}条记录   到第</a>
        </li>
        <li class="page-item">
            <input type="text" class="form-control" size="1" id="jumpInput" value="${requestScope.books.pageNo}">
        </li>
        <li class="page-item">
            <button type="button" class="btn btn-light" id="jumpBtn">页跳转</button>
        </li>
    </ul>
</nav>




</body>
</html>
